package com.gxa.controller.set;

import com.gxa.common.R;
import com.gxa.entity.SysActionLog;
import com.gxa.service.LogService;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

@Controller
@RequestMapping("/log")
@Api(value = "系统日志管理的所有操作测试",tags = "系统日志管理接口API")
public class LogController {

    @Autowired
    private LogService logService;

    /**
     * 分页查询所有系统日志
     * @param currentPage
     * @param pageSize
     * @return
     */
    @RequestMapping(value = "/queryAllLogsByPage",method = RequestMethod.GET)
    @ApiOperation(value = "查询所有系统日志接口",notes = "查询所有系统日志进行分页显示",httpMethod = "GET",response = R.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "currentPage",value = "当前页码数",required = true,dataType = "int",paramType = "query"),
            @ApiImplicitParam(name = "pageSize",value = "每页显示记录数",required = true,dataType = "int",paramType = "query")
    })
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    @ResponseBody
    public R queryAllLogsByPage(int currentPage,int pageSize){
        return logService.queryAllLogsByPage(currentPage,pageSize);
    }

    /**
     * 按条件分页查询系统日志
     * @param organization
     * @param operator
     * @param operationTime
     * @param operationContent
     * @return
     */
    @RequestMapping(value = "/queryConditionalLog",method = RequestMethod.GET)
    @ApiOperation(value = "按条件查询系统日志接口",notes = "按条件查询系统日志信息进行分页显示",httpMethod = "GET",response = R.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "organization",value = "组织",required = false,dataType = "String",paramType = "query"),
            @ApiImplicitParam(name = "operator",value = "操作人",required = false,dataType = "String",paramType = "query"),
            @ApiImplicitParam(name = "operationTime",value = "操作时间",required = false,dataType = "date",paramType = "query"),
            @ApiImplicitParam(name = "operationContent",value = "操作内容",required = false,dataType = "String",paramType = "query"),
            @ApiImplicitParam(name = "currentPage",value = "当前页码数",required = true,dataType = "int",paramType = "query"),
            @ApiImplicitParam(name = "pageSize",value = "每页显示记录数",required = true,dataType = "int",paramType = "query")
    })
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    @ResponseBody
    public R queryConditionalLog(String organization, String operator, @DateTimeFormat(pattern = "yyyy-MM-dd") Date operationTime, String operationContent,int currentPage,int pageSize){
        return logService.queryConditionalLog(organization,operator,operationTime,operationContent,currentPage,pageSize);
    }
}
